const Actions = {
  SET_USER_ID: 'SET_USER_ID',
  SET_ROLE: 'SET_ROLE',
  SET_MEDIA_STATUS: 'SET_MEDIA_STATUS',
  SET_ROOM: 'SET_ROOM',
  SET_USER_STREAM: 'SET_USER_STREAM'
}

/**
 * 设置当前浏览器用户ID
 * @param {String} userId
 */
export const setUserId = (userId) => {
  return {
    type: Actions.SET_USER_ID,
    userId
  }
}
/**
 * 设置当前用户的身份
 * @param {String} role 身份值 host,audience
 */
export const setRole = (role) => {
  return {
    type: Actions.SET_ROLE,
    role
  }
}
/**
 * 设置媒体流状态
 * @param {Boolean} openAudio
 * @param {Boolean} openCamera
 */
export const setMediaStatus = (data) => {
  return {
    type: Actions.SET_MEDIA_STATUS,
    ...data
  }
}
/**
 * 设置整个房间信息
 */
export const setRoomInfo = (roomInfo) => {
  return {
    type: Actions.SET_ROOM,
    roomInfo
  }
}
/**
 * 设置用户的数据流
 */
export const setUserStream = ({ userId, stream }) => {
  window.userStreamMap[ userId ] = stream
  return {
    type: Actions.SET_USER_STREAM,
    userId,
    streamId: Date.now()
  }
}
export default Actions
